package dao.impl;

import java.util.List;

import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import bean.Admin;
import dao.AdminDao;

public class AdminDaoImpl extends HibernateDaoSupport implements AdminDao {

	@Override
	public Admin findAdmin(Admin admin) {
		List l = this.getSessionFactory().getCurrentSession()
				.createCriteria(Admin.class)
				.add(Restrictions.eq("username", admin.getUsername()))
				.add(Restrictions.eq("password", admin.getPassword())).list();
		if (l.size() == 0)
			return null;
		else
			return (Admin) l.get(0);
	}

}
